<template>
    <div class="app-container">
        <div class="head">
            <img src="@/assets/img/Layout/position.png" />
            <p class="see-block">防伪全链路查询</p>
        </div>
        <div class="view-container">
            <el-row class="search">
                <div class="el-input el-input--small el-input--suffix" style="width:auto;">
                    <input
                        v-model="code"
                        placeholder="请扫码或者输入防伪码"
                        @keydown.enter="numberEnterDown()"
                        @keyup.enter="numberEnterUp()"
                        class="width230 mr20 el-input__inner"
                        ref="getFocus"
                    />
                </div>
                <el-button type="primary" icon="el-icon-search" size="mini" class="list-search btn-success" color="#5ED4D4"
                    @click="searchAnti()"
                >搜索</el-button>
            </el-row>
            <el-row class="searchResult border-top" v-if="show">
                <p>您扫描的码为：<span class="text">{{ scanCode }}</span></p>
            </el-row>
            <template v-if="searchData">
                <el-row class="searchResult">
                    <p class="result">查询结果如下：</p>
                    <p class="tag-group">公司名称：
                        <template v-if="JSON.stringify(searchData) == '[]'">
                            <span class="text">暂无数据</span>
                        </template>
                        <template v-else>
                            <el-tag v-for="(item, index) in searchData" :key="index" :type="type(index)" effect="plain" @click="val => onTagGroup(index, item.corporateName)">
                                {{ item.corporateName }}
                            </el-tag>
                        </template>
                    </p>
                    <p>产品名称：<span class="text">{{ searchProductName == '' ? '暂无数据' : searchProductName }}</span></p>
                </el-row>
                <template v-if="JSON.stringify(purchaseOrder) == '[]'">
                    <el-row class="antiItem">
                        <p class="result mb20">生产计划</p>
                        <el-table :data="productPlan" @row-click="handleView(productPlan, 'plan')" border key="productPlan">
                            <el-table-column label="序号" align="center" type="index" width="50" />
                            <el-table-column label="计划编码" align="center" prop="planCode" />
                            <el-table-column label="产品名称" align="center" prop="productBasicName" />
                            <el-table-column label="规格" align="center" prop="specification" />
                            <el-table-column label="批号" align="center" prop="batchNumber" />
                            <el-table-column label="计划数量" align="center" prop="planNum" />
                            <el-table-column label="完成数量" align="center" prop="endNum" />
                            <el-table-column :formatter="formatData" label="计划开始时间" align="center" prop="planStartTime" />
                            <el-table-column :formatter="formatData" label="计划结束时间" align="center" prop="planEndTime" />
                            <el-table-column label="状态" align="center" prop="plunStatus">
                                <template slot-scope="scope">
                                    <div v-if="scope.row.plunStatus == 0" style="color:#13C2C2">计划中</div>
                                    <div v-if="scope.row.plunStatus == 1" style="color:#13C2C2">进行中</div>
                                    <div v-if="scope.row.plunStatus == 2" style="color:#52C41A">已完成</div>
                                    <div v-if="scope.row.plunStatus == 3" style="color:#13C2C2">草稿</div>
                                </template>
                            </el-table-column>
                            <el-table-column label="审核状态" align="center" prop="approveStatus">
                                <template slot-scope="scope">
                                    <div v-if="scope.row.approveStatus == 0" style="color:#13C2C2">待审核</div>
                                    <div v-if="scope.row.approveStatus == 1" style="color:#52C41A">已审核</div>
                                    <div v-if="scope.row.approveStatus == 2" style="color:#fd562c">反审核</div>
                                    <div v-if="scope.row.approveStatus == 3" style="color:#fd562c">拒绝</div>
                                    <div v-if="scope.row.approveStatus == 4" style="color:#13C2C2"></div>
                                </template>
                            </el-table-column>
                            <el-table-column label="备注" align="center" prop="remark" />
                        </el-table>
                    </el-row>
                    <el-row class="antiItem">
                        <p class="result mb20">完工装箱</p>
                        <el-table :data="planFinish" @row-click="handleView(planFinish, 'planFinishing')" border key="planFinish">
                            <el-table-column label="序号" align="center" type="index" width="50" />
                            <el-table-column label="计划编号" align="center" prop="planCode" />
                            <el-table-column label="产品名称" align="center" prop="productBasicName" />
                            <el-table-column label="规格" align="center" prop="specification" />
                            <el-table-column label="批次号" align="center" prop="batchNumber" />
                            <el-table-column label="计划数量" align="center" prop="planNum" />
                            <el-table-column label="完成数量" align="center" prop="finishNum" />
                            <el-table-column label="状态" align="center" prop="status">
                                <template slot-scope="scope">
                                    <div v-if="scope.row.status == 0" style="color:#13C2C2">计划中</div>
                                    <div v-if="scope.row.status == 1" style="color:#13C2C2">生产中</div>
                                    <div v-if="scope.row.status == 2" style="color:#52C41A">已完成</div>
                                </template>
                            </el-table-column>
                        </el-table>
                    </el-row>
                    <el-row class="antiItem">
                        <p class="result mb20">成品入库</p>
                        <el-table :data="productStock" @row-click="handleView(productStock, 'productStock')" border key="productStock">
                            <el-table-column label="序号" align="center" type="index" width="50" />
                            <el-table-column label="计划编码" align="center" prop="planCode"/>
                            <el-table-column label="产品名称" align="center" prop="productBasicName"/>
                            <el-table-column label="规格" align="center" prop="specification"/>
                            <el-table-column label="产品批号" align="center" prop="batchNumber"/>
                            <el-table-column label="计划数量" align="center" prop="planNum" />
                            <el-table-column label="实际入库" align="center" prop="storeNum"/>
                            <el-table-column label="状态" align="center" prop="status">
                            <template slot-scope="scope">
                                <div v-if="scope.row.status == 0" style="color:#13C2C2">待入库</div>
                                <div v-if="scope.row.status == 1" style="color:#52C41A">已入库</div>
                                <div v-if="scope.row.status == 2" style="color:#52C41A">已完成</div>
                            </template>
                            </el-table-column>
                        </el-table>
                    </el-row>
                </template>
                <template v-else>
                    <el-row class="antiItem">
                        <p class="result mb20">采购订单</p>
                        <el-table :data="purchaseOrder" @row-click="handleView(purchaseOrder, 'purchaseOrder')" border key="purchaseOrder">
                            <el-table-column label="序号" align="center" type="index" width="50" />
                            <el-table-column label="订单编码"  align="center" prop="purchaseOrderCode"/>
                            <el-table-column label="供应商"  align="center" prop="supplierName"/>
                            <el-table-column label="产品名称" align="center" prop="productBasicName" >
                            <template slot-scope="scope">
                                <div v-for="(item, index) in scope.row.purchaseOrderProductList" :key="index">
                                {{ item.productBasicName }}
                                </div>
                            </template>
                            </el-table-column>
                            <el-table-column label="规格" align="center" prop="specification">
                            <template slot-scope="scope">
                                <div v-for="(item, index) in scope.row.purchaseOrderProductList" :key="index">
                                {{ item.specification }}
                                </div>
                            </template>
                            </el-table-column>
                            <el-table-column label="单位" align="center" prop="unit">
                            <template slot-scope="scope">
                                <div v-for="(item, index) in scope.row.purchaseOrderProductList" :key="index">
                                {{ item.unit }}
                                </div>
                            </template>
                            </el-table-column>
                            <el-table-column label="数量" align="center" prop="num">
                            <template slot-scope="scope">
                                <div v-for="(item, index) in scope.row.purchaseOrderProductList" :key="index">
                                {{ item.num }}
                                </div>
                            </template>
                            </el-table-column>
                            <el-table-column label="预计到货日期" align="center" prop="arrivalDate">
                            <template slot-scope="scope">
                                <div v-for="(item, index) in scope.row.purchaseOrderProductList" :key="index">
                                {{ item.arrivalDate }}
                                </div>
                            </template>
                            </el-table-column>
                            <el-table-column label="审核状态" align="center" prop="approvalStatus">
                            <template slot-scope="scope">
                                <div v-if="scope.row.approvalStatus == 0" style="color:#13C2C2">待审核</div>
                                <div v-if="scope.row.approvalStatus == 1" style="color:#52C41A">已审核</div>
                                <div v-if="scope.row.approvalStatus == 2" style="color:#fd562c">反审核</div>
                                <div v-if="scope.row.approvalStatus == 3" style="color:#fd562c">拒绝</div>
                            </template>
                            </el-table-column>
                        </el-table>
                    </el-row>
                    <el-row class="antiItem">
                        <p class="result mb20">采购入库</p>
                        <el-table :data="purInboundOrder" @row-click="handleView(purInboundOrder, 'purInboundOrder')" border key="purInboundOrder">
                            <el-table-column label="序号" align="center" type="index" width="50" />
                            <el-table-column label="入库单号"  align="center" prop="code"/>
                            <el-table-column label="关联采购单号" align="center" prop="purchaseOrderCode"/>
                            <el-table-column label="供应商" align="center" prop="supplierName"/>
                            <el-table-column label="产品名称" align="center" prop="productBasicName">
                            <template slot-scope="scope">
                                <div v-for="(item, index) in scope.row.detailList" :key="index">
                                {{ item.productBasicName }}
                                </div>
                            </template>
                            </el-table-column>
                            <el-table-column label="规格" align="center" prop="specification">
                            <template slot-scope="scope">
                                <div v-for="(item, index) in scope.row.detailList" :key="index">
                                {{ item.specification }}
                                </div>
                            </template>
                            </el-table-column>
                            <el-table-column label="订单数量" align="center" prop="purchaseNum">
                            <template slot-scope="scope">
                                <div v-for="(item, index) in scope.row.detailList" :key="index">
                                {{ item.purchaseNum }}
                                </div>
                            </template>
                            </el-table-column>
                            <el-table-column label="完成数量" align="center" prop="endNum">
                            <template slot-scope="scope">
                                <div v-for="(item, index) in scope.row.detailList" :key="index">
                                {{ item.endNum }}
                                </div>
                            </template>
                            </el-table-column>
                            <el-table-column label="入库时间" align="center" prop="warehouseTime"/>
                            <el-table-column label="状态" align="center" prop="status">
                            <template slot-scope="scope">
                                <div v-if="scope.row.status == 0" style="color:#13C2C2">待入库</div>
                                <div v-if="scope.row.status == 1" style="color:#52C41A">已入库</div>
                                <div v-if="scope.row.status == 11" style="color:#13C2C2">已提交</div>
                                <div v-if="scope.row.status == 4" style="color:#52C41A">部分入库</div>
                                <div v-if="scope.row.status == 3" style="color:#13C2C2">拒绝</div>
                            </template>
                            </el-table-column>
                        </el-table>
                    </el-row>
                </template>
                <el-row class="antiItem">
                    <p class="result mb20">销售订单</p>
                    <el-table :data="saleOrder" @row-click="handleView(saleOrder, 'salesOrder')" border key="saleOrder">
                        <el-table-column label="序号" align="center" type="index" width="50" />
                        <el-table-column label="单据编码" align="center" prop="orderCode" />
                        <el-table-column label="产品名称" align="center" prop="productBasicName">
                            <template slot-scope="scope">
                                <div v-for="(item, index) in scope.row.salesOrderDetailList" :key="index">
                                    {{ item.productBasicName }}
                                </div>
                            </template>
                        </el-table-column>
                        <el-table-column label="规格" align="center" prop="productSpace">
                        <template slot-scope="scope">
                            <div v-for="(item, index) in scope.row.salesOrderDetailList" :key="index">
                            {{ item.productSpace }}
                            </div>
                        </template>
                        </el-table-column>
                        <el-table-column label="批号" align="center" prop="batchNumber">
                            <template slot-scope="scope">
                                <div v-for="(item, index) in scope.row.salesOrderDetailList" :key="index">
                                    {{ item.batchNumber }}
                                </div>
                            </template>
                        </el-table-column>
                        <el-table-column label="计划数量" align="center" prop="total">
                            <template slot-scope="scope">
                                <div v-for="(item, index) in scope.row.salesOrderDetailList" :key="index">
                                    {{ item.total }}
                                </div>
                            </template>
                        </el-table-column>
                        <el-table-column label="完成数量" align="center" prop="outStore">
                            <template slot-scope="scope">
                                <div v-for="(item, index) in scope.row.salesOrderDetailList" :key="index">
                                    {{ item.outStore }}
                                </div>
                            </template>
                        </el-table-column>
                        <el-table-column label="状态" align="center" prop="status">
                            <template slot-scope="scope">
                                <div v-if="scope.row.status == 1" style="color:#13C2C2">待审核</div>
                                <div v-if="scope.row.status == 2" style="color:#52C41A">已审核</div>
                                <div v-if="scope.row.status == 3" style="color:#52C41A">已完成</div>
                                <div v-if="scope.row.status == 4" style="color:#52C41A">部分完成</div>
                                <div v-if="scope.row.status == 9" style="color:#52C41A">自动</div>
                            </template>
                        </el-table-column>
                        <el-table-column label="计划发货数量" align="center" prop="total">
                            <template slot-scope="scope">
                                <div v-for="(item, index) in scope.row.salesOrderDetailList" :key="index">
                                    {{ item.total }}
                                </div>
                            </template>
                        </el-table-column>
                        <el-table-column label="备注" align="center" prop="remark" />
                    </el-table>
                </el-row>
                <el-row class="antiItem">
                    <p class="result mb20">销售出库</p>
                    <el-table :data="productOutOrder" @row-click="handleView(productOutOrder, 'outSale')" border key="productOutOrder">
                        <el-table-column label="序号" align="center" type="index" width="50" />
                        <el-table-column label="单据编码"  align="center" prop="code" />
                        <el-table-column label="产品名称"  align="center" prop="productBasicName">
                            <template slot-scope="scope">
                                <div v-for="(item, index) in scope.row.orderDetails" :key="index">
                                    {{ item.productBasicName }}
                                </div>
                            </template>
                        </el-table-column>
                        <el-table-column label="规格"  align="center" prop="productSpace">
                        <template slot-scope="scope">
                            <div v-for="(item, index) in scope.row.orderDetails" :key="index">
                            {{ item.productSpace }}
                            </div>
                        </template>
                        </el-table-column>
                        <el-table-column label="批号"  align="center" prop="batchNumber">
                            <template slot-scope="scope">
                                <div v-for="(item, index) in scope.row.orderDetails" :key="index">
                                    {{ item.batchNumber }}
                                </div>
                            </template>
                        </el-table-column>
                        <el-table-column label="订单数量"  align="center" prop="orderNum">
                            <template slot-scope="scope">
                                <div v-for="(item, index) in scope.row.orderDetails" :key="index">
                                    {{ item.orderNum }}
                                </div>
                            </template>
                        </el-table-column>
                        <el-table-column label="计划数量"  align="center" prop="total">
                        <template slot-scope="scope">
                            <div v-for="(item, index) in scope.row.orderDetails" :key="index">
                            {{ item.total }}
                            </div>
                        </template>
                        </el-table-column>
                        <el-table-column label="完成数量"  align="center" prop="outStore">
                        <template slot-scope="scope">
                            <div v-for="(item, index) in scope.row.orderDetails" :key="index">
                            {{ item.outStore }}
                            </div>
                        </template>
                        </el-table-column>
                        <el-table-column label="状态" align="center" prop="status">
                        <template slot-scope="scope">
                            <div v-if="scope.row.status == 0" style="color:#13C2C2">待出库</div>
                            <div v-if="scope.row.status == 1" style="color:#52C41A">部分出库</div>
                            <div v-if="scope.row.status == 2" style="color:#52C41A">已出库</div>
                        </template>
                        </el-table-column>
                        <el-table-column label="开始时间"  align="center" prop="startTime" />
                        <el-table-column label="结束时间"  align="center" prop="endTime" />
                        <el-table-column label="备注"  align="center" prop="remark">
                            <template slot-scope="scope">
                                <div v-for="(item, index) in scope.row.orderDetails" :key="index">
                                    {{ item.remark }}
                                </div>
                            </template>
                        </el-table-column>
                    </el-table>
                </el-row>
            </template>
            <template v-else>
                <el-row class="antiItem">
                    <p class="result mb20">生产计划</p>
                    <el-table :data="productPlan" @row-click="handleView(productPlan, 'plan')" border>
                        <el-table-column label="序号" align="center" type="index" width="50" />
                        <el-table-column label="计划编码" align="center" prop="planCode" />
                        <el-table-column label="产品名称" align="center" prop="productBasicName" />
                        <el-table-column label="规格" align="center" prop="specification" />
                        <el-table-column label="批号" align="center" prop="batchNumber" />
                        <el-table-column label="计划数量" align="center" prop="planNum" />
                        <el-table-column label="完成数量" align="center" prop="endNum" />
                        <el-table-column :formatter="formatData" label="计划开始时间" align="center" prop="planStartTime" />
                        <el-table-column :formatter="formatData" label="计划结束时间" align="center" prop="planEndTime" />
                        <el-table-column label="状态" align="center" prop="plunStatus">
                            <template slot-scope="scope">
                                <div v-if="scope.row.plunStatus == 0" style="color:#13C2C2">计划中</div>
                                <div v-if="scope.row.plunStatus == 1" style="color:#13C2C2">进行中</div>
                                <div v-if="scope.row.plunStatus == 2" style="color:#52C41A">已完成</div>
                                <div v-if="scope.row.plunStatus == 3" style="color:#13C2C2">草稿</div>
                            </template>
                        </el-table-column>
                        <el-table-column label="审核状态" align="center" prop="approveStatus">
                            <template slot-scope="scope">
                                <div v-if="scope.row.approveStatus == 0" style="color:#13C2C2">待审核</div>
                                <div v-if="scope.row.approveStatus == 1" style="color:#52C41A">已审核</div>
                                <div v-if="scope.row.approveStatus == 2" style="color:#fd562c">反审核</div>
                                <div v-if="scope.row.approveStatus == 3" style="color:#fd562c">拒绝</div>
                                <div v-if="scope.row.approveStatus == 4" style="color:#13C2C2"></div>
                            </template>
                        </el-table-column>
                        <el-table-column label="备注" align="center" prop="remark" />
                    </el-table>
                </el-row>
                <el-row class="antiItem">
                    <p class="result mb20">完工装箱</p>
                    <el-table :data="planFinish" @row-click="handleView(planFinish, 'planFinishing')" border>
                        <el-table-column label="序号" align="center" type="index" width="50" />
                        <el-table-column label="计划编号" align="center" prop="planCode" />
                        <el-table-column label="产品名称" align="center" prop="productBasicName" />
                        <el-table-column label="规格" align="center" prop="specification" />
                        <el-table-column label="批次号" align="center" prop="batchNumber" />
                        <el-table-column label="计划数量" align="center" prop="planNum" />
                        <el-table-column label="完成数量" align="center" prop="finishNum" />
                        <el-table-column label="状态" align="center" prop="status">
                            <template slot-scope="scope">
                                <div v-if="scope.row.status == 0" style="color:#13C2C2">计划中</div>
                                <div v-if="scope.row.status == 1" style="color:#13C2C2">生产中</div>
                                <div v-if="scope.row.status == 2" style="color:#52C41A">已完成</div>
                            </template>
                        </el-table-column>
                    </el-table>
                </el-row>
                <el-row class="antiItem">
                    <p class="result mb20">成品入库</p>
                    <el-table :data="productStock" @row-click="handleView(productStock, 'productStock')" border>
                        <el-table-column label="序号" align="center" type="index" width="50" />
                        <el-table-column label="计划编码" align="center" prop="planCode"/>
                        <el-table-column label="产品名称" align="center" prop="productBasicName"/>
                        <el-table-column label="规格" align="center" prop="specification"/>
                        <el-table-column label="产品批号" align="center" prop="batchNumber"/>
                        <el-table-column label="计划数量" align="center" prop="planNum" />
                        <el-table-column label="实际入库" align="center" prop="storeNum"/>
                        <el-table-column label="状态" align="center" prop="status">
                        <template slot-scope="scope">
                            <div v-if="scope.row.status == 0" style="color:#13C2C2">待入库</div>
                            <div v-if="scope.row.status == 1" style="color:#52C41A">已入库</div>
                            <div v-if="scope.row.status == 2" style="color:#52C41A">已完成</div>
                        </template>
                        </el-table-column>
                    </el-table>
                </el-row>
                <el-row class="antiItem">
                    <p class="result mb20">采购订单</p>
                    <el-table :data="purchaseOrder" @row-click="handleView(purchaseOrder, 'purchaseOrder')" border>
                        <el-table-column label="序号" align="center" type="index" width="50" />
                        <el-table-column label="订单编码"  align="center" prop="purchaseOrderCode"/>
                        <el-table-column label="供应商"  align="center" prop="supplierName"/>
                        <el-table-column label="产品名称" align="center" prop="productBasicName" >
                        <template slot-scope="scope">
                            <div v-for="(item, index) in scope.row.purchaseOrderProductList" :key="index">
                            {{ item.productBasicName }}
                            </div>
                        </template>
                        </el-table-column>
                        <el-table-column label="规格" align="center" prop="specification">
                        <template slot-scope="scope">
                            <div v-for="(item, index) in scope.row.purchaseOrderProductList" :key="index">
                            {{ item.specification }}
                            </div>
                        </template>
                        </el-table-column>
                        <el-table-column label="单位" align="center" prop="unit">
                        <template slot-scope="scope">
                            <div v-for="(item, index) in scope.row.purchaseOrderProductList" :key="index">
                            {{ item.unit }}
                            </div>
                        </template>
                        </el-table-column>
                        <el-table-column label="数量" align="center" prop="num">
                        <template slot-scope="scope">
                            <div v-for="(item, index) in scope.row.purchaseOrderProductList" :key="index">
                            {{ item.num }}
                            </div>
                        </template>
                        </el-table-column>
                        <el-table-column label="预计到货日期" align="center" prop="arrivalDate">
                        <template slot-scope="scope">
                            <div v-for="(item, index) in scope.row.purchaseOrderProductList" :key="index">
                            {{ item.arrivalDate }}
                            </div>
                        </template>
                        </el-table-column>
                        <el-table-column label="审核状态" align="center" prop="approvalStatus">
                        <template slot-scope="scope">
                            <div v-if="scope.row.approvalStatus == 0" style="color:#13C2C2">待审核</div>
                            <div v-if="scope.row.approvalStatus == 1" style="color:#52C41A">已审核</div>
                            <div v-if="scope.row.approvalStatus == 2" style="color:#fd562c">反审核</div>
                            <div v-if="scope.row.approvalStatus == 3" style="color:#fd562c">拒绝</div>
                        </template>
                        </el-table-column>
                    </el-table>
                </el-row>
                <el-row class="antiItem">
                    <p class="result mb20">采购入库</p>
                    <el-table :data="purInboundOrder" @row-click="handleView(purInboundOrder, 'purInboundOrder')" border>
                        <el-table-column label="序号" align="center" type="index" width="50" />
                        <el-table-column label="入库单号"  align="center" prop="code"/>
                        <el-table-column label="关联采购单号" align="center" prop="purchaseOrderCode"/>
                        <el-table-column label="供应商" align="center" prop="supplierName"/>
                        <el-table-column label="产品名称" align="center" prop="productBasicName">
                        <template slot-scope="scope">
                            <div v-for="(item, index) in scope.row.detailList" :key="index">
                            {{ item.productBasicName }}
                            </div>
                        </template>
                        </el-table-column>
                        <el-table-column label="规格" align="center" prop="specification">
                        <template slot-scope="scope">
                            <div v-for="(item, index) in scope.row.detailList" :key="index">
                            {{ item.specification }}
                            </div>
                        </template>
                        </el-table-column>
                        <el-table-column label="订单数量" align="center" prop="purchaseNum">
                        <template slot-scope="scope">
                            <div v-for="(item, index) in scope.row.detailList" :key="index">
                            {{ item.purchaseNum }}
                            </div>
                        </template>
                        </el-table-column>
                        <el-table-column label="完成数量" align="center" prop="endNum">
                        <template slot-scope="scope">
                            <div v-for="(item, index) in scope.row.detailList" :key="index">
                            {{ item.endNum }}
                            </div>
                        </template>
                        </el-table-column>
                        <el-table-column label="入库时间" align="center" prop="warehouseTime"/>
                        <el-table-column label="状态" align="center" prop="status">
                        <template slot-scope="scope">
                            <div v-if="scope.row.status == 0" style="color:#13C2C2">待入库</div>
                            <div v-if="scope.row.status == 1" style="color:#52C41A">已入库</div>
                            <div v-if="scope.row.status == 11" style="color:#13C2C2">已提交</div>
                            <div v-if="scope.row.status == 4" style="color:#52C41A">部分入库</div>
                            <div v-if="scope.row.status == 3" style="color:#13C2C2">拒绝</div>
                        </template>
                        </el-table-column>
                    </el-table>
                </el-row>
                <el-row class="antiItem">
                    <p class="result mb20">销售订单</p>
                    <el-table :data="saleOrder" @row-click="handleView(saleOrder, 'salesOrder')" border>
                        <el-table-column label="序号" align="center" type="index" width="50" />
                        <el-table-column label="单据编码" align="center" prop="orderCode" />
                        <el-table-column label="产品名称" align="center" prop="productBasicName">
                            <template slot-scope="scope">
                                <div v-for="(item, index) in scope.row.salesOrderDetailList" :key="index">
                                    {{ item.productBasicName }}
                                </div>
                            </template>
                        </el-table-column>
                        <el-table-column label="规格" align="center" prop="productSpace">
                        <template slot-scope="scope">
                            <div v-for="(item, index) in scope.row.salesOrderDetailList" :key="index">
                            {{ item.productSpace }}
                            </div>
                        </template>
                        </el-table-column>
                        <el-table-column label="批号" align="center" prop="batchNumber">
                            <template slot-scope="scope">
                                <div v-for="(item, index) in scope.row.salesOrderDetailList" :key="index">
                                    {{ item.batchNumber }}
                                </div>
                            </template>
                        </el-table-column>
                        <el-table-column label="计划数量" align="center" prop="total">
                            <template slot-scope="scope">
                                <div v-for="(item, index) in scope.row.salesOrderDetailList" :key="index">
                                    {{ item.total }}
                                </div>
                            </template>
                        </el-table-column>
                        <el-table-column label="完成数量" align="center" prop="outStore">
                            <template slot-scope="scope">
                                <div v-for="(item, index) in scope.row.salesOrderDetailList" :key="index">
                                    {{ item.outStore }}
                                </div>
                            </template>
                        </el-table-column>
                        <el-table-column label="状态" align="center" prop="status">
                            <template slot-scope="scope">
                                <div v-if="scope.row.status == 1" style="color:#13C2C2">待审核</div>
                                <div v-if="scope.row.status == 2" style="color:#52C41A">已审核</div>
                                <div v-if="scope.row.status == 3" style="color:#52C41A">已完成</div>
                                <div v-if="scope.row.status == 4" style="color:#52C41A">部分完成</div>
                                <div v-if="scope.row.status == 9" style="color:#52C41A">自动</div>
                            </template>
                        </el-table-column>
                        <el-table-column label="计划发货数量" align="center" prop="total">
                            <template slot-scope="scope">
                                <div v-for="(item, index) in scope.row.salesOrderDetailList" :key="index">
                                    {{ item.total }}
                                </div>
                            </template>
                        </el-table-column>
                        <el-table-column label="备注" align="center" prop="remark" />
                    </el-table>
                </el-row>
                <el-row class="antiItem">
                    <p class="result mb20">销售出库</p>
                    <el-table :data="productOutOrder" @row-click="handleView(productOutOrder, 'outSale')" border>
                        <el-table-column label="序号" align="center" type="index" width="50" />
                        <el-table-column label="单据编码"  align="center" prop="code" />
                        <el-table-column label="产品名称"  align="center" prop="productBasicName">
                            <template slot-scope="scope">
                                <div v-for="(item, index) in scope.row.orderDetails" :key="index">
                                    {{ item.productBasicName }}
                                </div>
                            </template>
                        </el-table-column>
                        <el-table-column label="规格"  align="center" prop="productSpace">
                        <template slot-scope="scope">
                            <div v-for="(item, index) in scope.row.orderDetails" :key="index">
                            {{ item.productSpace }}
                            </div>
                        </template>
                        </el-table-column>
                        <el-table-column label="批号"  align="center" prop="batchNumber">
                            <template slot-scope="scope">
                                <div v-for="(item, index) in scope.row.orderDetails" :key="index">
                                    {{ item.batchNumber }}
                                </div>
                            </template>
                        </el-table-column>
                        <el-table-column label="订单数量"  align="center" prop="orderNum">
                            <template slot-scope="scope">
                                <div v-for="(item, index) in scope.row.orderDetails" :key="index">
                                    {{ item.orderNum }}
                                </div>
                            </template>
                        </el-table-column>
                        <el-table-column label="计划数量"  align="center" prop="total">
                        <template slot-scope="scope">
                            <div v-for="(item, index) in scope.row.orderDetails" :key="index">
                            {{ item.total }}
                            </div>
                        </template>
                        </el-table-column>
                        <el-table-column label="完成数量"  align="center" prop="outStore">
                        <template slot-scope="scope">
                            <div v-for="(item, index) in scope.row.orderDetails" :key="index">
                            {{ item.outStore }}
                            </div>
                        </template>
                        </el-table-column>
                        <el-table-column label="状态" align="center" prop="status">
                        <template slot-scope="scope">
                            <div v-if="scope.row.status == 0" style="color:#13C2C2">待出库</div>
                            <div v-if="scope.row.status == 1" style="color:#52C41A">部分出库</div>
                            <div v-if="scope.row.status == 2" style="color:#52C41A">已出库</div>
                        </template>
                        </el-table-column>
                        <el-table-column label="开始时间"  align="center" prop="startTime" />
                        <el-table-column label="结束时间"  align="center" prop="endTime" />
                        <el-table-column label="备注"  align="center" prop="remark">
                            <template slot-scope="scope">
                                <div v-for="(item, index) in scope.row.orderDetails" :key="index">
                                    {{ item.remark }}
                                </div>
                            </template>
                        </el-table-column>
                    </el-table>
                </el-row>
            </template>
        </div>
    </div>
</template>

<script>
import { searchAllAnti } from "@/api/system/warehouse/anti"
import { queryWarehouse } from "@/api/system/warehouse/warehouse"
export default {
    name: "anti",
    data() {
        return {
            code: '',
            scanCode: '',
            searchData: '',
            searchProductName: '',
            show: false,
            productPlan: [], // 生产计划单
            productQrCodeLog: [], // 码生成
            materialRequisition: [], // 领料单
            planFinish: [], // 完工装箱
            productStock: [], // 成品入库
            purchaseOrder: [], // 采购订单
            purInboundOrder: [], // 采购入库
            saleOrder: [], // 销售订单
            productOutRelease: [], // 发货通知单
            productOutOrder: [], // 销售出库单
            productOutSale: [], // 销售出库单(旧)
            current: 0,
        }
    },
    mounted(){
        this.$refs.getFocus.focus()
    },
    methods: {
        formatData(row, column, cellValue, index){
            if(cellValue !== null){
                let s = new Date(cellValue).toLocaleString()
                return s
            }
        },
        numberEnterDown() {
            this.keyDownTime = new Date().getTime()
        },
        numberEnterUp() {
            this.keyUpTime = new Date().getTime()
            if (this.keyUpTime - this.keyDownTime < 30) {
                // 扫码枪触发
                this.show = true
                let code = this.common.codeRule(this.code)
                this.scanCode = code
                this.code = ''
                this.searchData = ''
                this.productPlan = []
                this.productQrCodeLog = []
                this.materialRequisition = []
                this.planFinish = []
                this.saleOrder = []
                this.productOutRelease = []
                this.productOutOrder = []
                this.productOutSale = []
                searchAllAnti(code).then(res => {
                    this.searchData = res.data ? res.data : ''
                    this.searchProductName = res.data ? res.data[0].antiFakeBody.productBasicName : ''
                    let data = res.data ? res.data[0].antiFakeBody : ''
                    if(data && data !== ''){
                        if(data.productPlan){
                            this.productPlan.push(data.productPlan)
                        }
                        if(data.productQrCodeLog){
                            this.productQrCodeLog.push(data.productQrCodeLog)
                        }
                        if(data.materialRequisition){
                            this.materialRequisition.push(data.materialRequisition)
                            this.getWarehouseList()
                        }
                        if(data.planFinish){
                            this.planFinish.push(data.planFinish)
                        }
                        if(data.salesOrder){
                            this.saleOrder.push(data.salesOrder)
                        }
                        if(data.productOutRelease){
                            this.productOutRelease.push(data.productOutRelease)
                        }
                        if(data.productOutOrder){
                            this.productOutOrder.push(data.productOutOrder)
                        }
                        if(data.productOutSale){
                            this.productOutSale.push(data.productOutSale)
                        }
                        if(data.productStock){
                            this.productStock.push(data.productStock)
                        }
                        if(data.purchaseOrder){
                            this.purchaseOrder.push(data.purchaseOrder)
                        }
                        if(data.purInboundOrder){
                            this.purInboundOrder.push(data.purInboundOrder)
                        }
                    }
                })
            }else{
                // 直接按键盘触发
                this.show = true
                let code = this.common.codeRule(this.code)
                this.scanCode = code
                this.code = ''
                this.searchData = ''
                this.productPlan = []
                this.productQrCodeLog = []
                this.materialRequisition = []
                this.planFinish = []
                this.saleOrder = []
                this.productOutRelease = []
                this.productOutOrder = []
                this.productOutSale = []
                searchAllAnti(code).then(res => {
                    this.searchData = res.data ? res.data : ''
                    this.searchProductName = res.data ? res.data[0].antiFakeBody.productBasicName : ''
                    let data = res.data ? res.data[0].antiFakeBody : ''
                    if(data && data !== ''){
                        if(data.productPlan){
                            this.productPlan.push(data.productPlan)
                        }
                        if(data.productQrCodeLog){
                            this.productQrCodeLog.push(data.productQrCodeLog)
                        }
                        if(data.materialRequisition){
                            this.materialRequisition.push(data.materialRequisition)
                            this.getWarehouseList()
                        }
                        if(data.planFinish){
                            this.planFinish.push(data.planFinish)
                        }
                        if(data.salesOrder){
                            this.saleOrder.push(data.salesOrder)
                        }
                        if(data.productOutRelease){
                            this.productOutRelease.push(data.productOutRelease)
                        }
                        if(data.productOutOrder){
                            this.productOutOrder.push(data.productOutOrder)
                        }
                        if(data.productOutSale){
                            this.productOutSale.push(data.productOutSale)
                        }
                        if(data.productStock){
                            this.productStock.push(data.productStock)
                        }
                        if(data.purchaseOrder){
                            this.purchaseOrder.push(data.purchaseOrder)
                        }
                        if(data.purInboundOrder){
                            this.purInboundOrder.push(data.purInboundOrder)
                        }
                    }
                })
            }
        },
        type(index){
            if(index == this.current){
                return 'success'
            }else{
                return 'info'
            }
        },
        onTagGroup(index, val){
            this.current = index
            this.type(index)
            this.productPlan = []
            this.productQrCodeLog = []
            this.materialRequisition = []
            this.planFinish = []
            this.productStock = []
            this.purchaseOrder = []
            this.purInboundOrder = []
            this.saleOrder = []
            this.productOutRelease = []
            this.productOutOrder = []
            this.productOutSale = []
            let data = this.searchData.find(item => {
                return val == item.corporateName
            })
            if(data && data !== ''){
                let arr = data.antiFakeBody
                this.searchProductName = arr.productBasicName ? arr.productBasicName : ''
                if(arr.productPlan){
                    this.productPlan.push(arr.productPlan)
                }
                if(arr.productQrCodeLog){
                    this.productQrCodeLog.push(arr.productQrCodeLog)
                }
                if(arr.materialRequisition){
                    this.materialRequisition.push(arr.materialRequisition)
                    this.getWarehouseList()
                }
                if(arr.planFinish){
                    this.planFinish.push(arr.planFinish)
                }
                if(arr.salesOrder){
                    this.saleOrder.push(arr.salesOrder)
                }
                if(arr.productOutRelease){
                    this.productOutRelease.push(arr.productOutRelease)
                }
                if(arr.productOutOrder){
                    this.productOutOrder.push(arr.productOutOrder)
                }
                if(arr.productOutSale){
                    this.productOutSale.push(arr.productOutSale)
                }
                if(arr.productStock){
                    this.productStock.push(arr.productStock)
                }
                if(arr.purchaseOrder){
                    this.purchaseOrder.push(arr.purchaseOrder)
                }
                if(arr.purInboundOrder){
                    this.purInboundOrder.push(arr.purInboundOrder)
                }
            }
        },
        // 获取数据
        searchAnti() {
            this.show = true
            let code = this.common.codeRule(this.code)
            // console.log(code)
            this.scanCode = code
            this.code = ''
            this.searchData = ''
            this.productPlan = []
            this.productQrCodeLog = []
            this.materialRequisition = []
            this.planFinish = []
            this.productStock = []
            this.purchaseOrder = []
            this.purInboundOrder = []
            this.saleOrder = []
            this.productOutRelease = []
            this.productOutOrder = []
            this.productOutSale = []
            searchAllAnti(code).then(res => {
                this.searchData = res.data ? res.data : ''
                this.searchProductName = res.data ? res.data[0].antiFakeBody.productBasicName : ''
                let data = res.data ? res.data[0].antiFakeBody : ''
                if(data && data !== ''){
                    if(data.productPlan){
                        this.productPlan.push(data.productPlan)
                    }
                    if(data.productQrCodeLog){
                        this.productQrCodeLog.push(data.productQrCodeLog)
                    }
                    if(data.materialRequisition){
                        this.materialRequisition.push(data.materialRequisition)
                        this.getWarehouseList()
                    }
                    if(data.planFinish){
                        this.planFinish.push(data.planFinish)
                    }
                    if(data.salesOrder){
                        this.saleOrder.push(data.salesOrder)
                    }
                    if(data.productOutRelease){
                        this.productOutRelease.push(data.productOutRelease)
                    }
                    if(data.productOutOrder){
                        this.productOutOrder.push(data.productOutOrder)
                    }
                    if(data.productOutSale){
                        this.productOutSale.push(data.productOutSale)
                    }
                    if(data.productStock){
                        this.productStock.push(data.productStock)
                    }
                    if(data.purchaseOrder){
                        this.purchaseOrder.push(data.purchaseOrder)
                    }
                    if(data.purInboundOrder){
                        this.purInboundOrder.push(data.purInboundOrder)
                    }
                }
            })
        },
        // 获取仓库列表
        getWarehouseList(){
            queryWarehouse().then(res => {
                if(res.code == 200){
                    this.searchData.materialRequisition.details.forEach(i => {
                        console.log(i)
                        let dataList = res.data.find(item => {
                            return item.warehouseId == i.warehouse
                        })
                        if(dataList != undefined){
                            i.warehouse = dataList.name
                        }
                    })
                }
            })
        },
        // 查看详情
        handleView(row, type) {
            if(type == 'plan'){
                this.$router.push({path:"/production/plan/detail",query:{id: row[0].id}})
            }else if(type == 'materialRequisition'){
                this.$router.push({path:"/warehouse/materialRequisition/detail",query:{id: row[0].id}})
            }else if(type == 'planFinishing'){
                this.$router.push({path:"/production/planfinish/detail",query:{id: row[0].id}})
            }else if(type == 'salesOrder'){
                this.$router.push({path:"/sales/salesOrder/detail", query:{id: row[0].id}})
            }else if(type == 'notice'){
                if(row[0].generateType == '3'){
                    this.$router.push({path:"/production/notice/oemDetail",query:{id: row[0].id}})
                }else{
                    this.$router.push({path:"/production/notice/detail",query:{id: row[0].id}})
                }
            }else if(type == 'outSale'){
                this.$router.push({path:"/sales/outSale/detail",query:{id: row[0].id}})
            }else if(type == 'productOutSale'){
                this.$router.push({path:"/production/oldOutSale/detail",query:{id: row[0].id}})
            }else if(type == 'productStock'){
              this.$router.push({path:"/production/productStock/detail",query:{id: row[0].id}})
            }else if(type == 'purchaseOrder'){
              this.$router.push({path:"/purchase/purchaseOrder/detail",query:{id: row[0].id}})
            }else if(type == 'purInboundOrder'){
              this.$router.push({path:"/purchase/purchaseStorage/detail",query:{id: row[0].id}})
            }
        }
    }
}
</script>

<style scoped>
.search {
    display: flex;
    padding-bottom: 20px;
}
.border-top {
    border-top: 1px solid #ccc;
}
.searchResult {
    font-size: 15px;
    color: #333;
    line-height: 40px;
}
.searchResult p span.text{
    font-size: 14px;
    color: #000;
    font-weight: bold;
}
.result {
    font-size: 16px;
    font-weight: bold;
}
.antiItem {
    margin: 15px 0;
}
.tag-group span{
    font-size: 13px;
}
.tag-group .el-tag{
    cursor: pointer;
}
.tag-group .el-tag+.el-tag {
    margin-left: 10px;
}
.el-tag--plain.el-tag--success{
    background-color: white;
    border-color: #28C6C6;
    color: #28C6C6;
}
</style>
